function form(a) {
    if (a < 10) {
        return '0' + a;
    } else {
        return a;
    }
}

function createTime(ctimeMs) {
    var date = new Date(ctimeMs); //转换成时间戳格式获取对应的年月日，时分秒
    var y = date.getFullYear();
    var m = date.getMonth() + 1;
    var d = date.getDate();
    var h = date.getHours();
    var mi = date.getMinutes();
    return y + '-' + form(m) + '-' + form(d) + ' ' + form(h) + ":" + form(mi);

}
const fs = require('fs');

const path = require('path');
var filePath = path.join(__dirname, './2.txt');

var fileObj = fs.statSync(filePath);

var ctimeMs = fileObj.ctimeMs;
// var date = new Date(ctimeMs);

console.log(createTime(ctimeMs));
// console.log(fileObj);